package com.ruoyi.coupon.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.coupon.mapper.TbCouponRecordMapper;
import com.ruoyi.coupon.domain.TbCouponRecord;
import com.ruoyi.coupon.service.ITbCouponRecordService;

/**
 * 优惠券领取记录Service业务层处理
 * 
 * @author gzc
 * @date 2023-04-27
 */
@Service
public class TbCouponRecordServiceImpl implements ITbCouponRecordService 
{
    @Autowired
    private TbCouponRecordMapper tbCouponRecordMapper;

    /**
     * 查询优惠券领取记录
     * 
     * @param couponRecordId 优惠券领取记录主键
     * @return 优惠券领取记录
     */
    @Override
    public TbCouponRecord selectTbCouponRecordByCouponRecordId(Long couponRecordId)
    {
        return tbCouponRecordMapper.selectTbCouponRecordByCouponRecordId(couponRecordId);
    }

    /**
     * 查询优惠券领取记录列表
     * 
     * @param tbCouponRecord 优惠券领取记录
     * @return 优惠券领取记录
     */
    @Override
    public List<TbCouponRecord> selectTbCouponRecordList(TbCouponRecord tbCouponRecord)
    {
        return tbCouponRecordMapper.selectTbCouponRecordList(tbCouponRecord);
    }

    /**
     * 新增优惠券领取记录
     * 
     * @param tbCouponRecord 优惠券领取记录
     * @return 结果
     */
    @Override
    public int insertTbCouponRecord(TbCouponRecord tbCouponRecord)
    {
        tbCouponRecord.setCreateTime(DateUtils.getNowDate());
        return tbCouponRecordMapper.insertTbCouponRecord(tbCouponRecord);
    }

    /**
     * 修改优惠券领取记录
     * 
     * @param tbCouponRecord 优惠券领取记录
     * @return 结果
     */
    @Override
    public int updateTbCouponRecord(TbCouponRecord tbCouponRecord)
    {
        return tbCouponRecordMapper.updateTbCouponRecord(tbCouponRecord);
    }

    /**
     * 批量删除优惠券领取记录
     * 
     * @param couponRecordIds 需要删除的优惠券领取记录主键
     * @return 结果
     */
    @Override
    public int deleteTbCouponRecordByCouponRecordIds(Long[] couponRecordIds)
    {
        return tbCouponRecordMapper.deleteTbCouponRecordByCouponRecordIds(couponRecordIds);
    }

    /**
     * 删除优惠券领取记录信息
     * 
     * @param couponRecordId 优惠券领取记录主键
     * @return 结果
     */
    @Override
    public int deleteTbCouponRecordByCouponRecordId(Long couponRecordId)
    {
        return tbCouponRecordMapper.deleteTbCouponRecordByCouponRecordId(couponRecordId);
    }

    @Override
    public TbCouponRecord isReceiveByUserId(Long couponId, Long userId) {
        return tbCouponRecordMapper.isReceiveByUserId(couponId,userId);
    }
}
